<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://eureka.yigolden.net/stringutils/sutaglib/1.0" prefix="su"%>
<c:set var="targetCategoryID" value="0" />
<c:forEach var="bookcategory" items="${bookcategories}">
 <c:if test="${bookcategory.CID eq param.category }">
  <c:set var="targetCategoryID" value="${bookcategory.CID }" />
 </c:if>
</c:forEach>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>搜索结果</title>
<link type="text/css" href="${staticResources}/css/searchbookresult.css" rel="stylesheet" />
<script type="text/javascript" src="${staticResources}/js/ajax.js"></script>
<script type="text/javascript">
function page_load() {
	document.getElementById("category").value = "${targetCategoryID }";
	
}

function collect(beid)
{
	//var redirect_url = document.getElementById("redirect_url").value;
	var mode = "ajax";
	
	var params="beid=" + encodeURIComponent(beid);
	//params+="&redirect_url="+encodeURIComponent(redirect_url);
	params+="&mode="+encodeURIComponent(mode);

	doAjax("AddToFavorite"
			,params,function(rst){
	var rst=eval('(' +rst+ ')');
	if(rst.status == 0)
	{
		window.alert("成功加入收藏夹！");
	}
	else 
	{
		window.alert(rst.message);
	} 
	});
}
</script>	
</head>
<body onload="page_load()">
<div id="header">
  <div id="hy">
    <c:if test="${user eq null }">
    <div id="logo">欢迎光临中国药科大学二手书交易平台!请<span><a href="${contextPath }/Account/Login">登录</a></span> 免费<span><a href="${contextPath }/Account/Register">注册</a></span></div>
    </c:if>
    <c:if test="${user ne null }">
    <div id="sc">
      <ul>
        <li><a href="${contextPath }/Account/Logout">注销</a></li>
        <li><a href="${contextPath }/Me?content=201">收藏夹</a></li>
        <li><a href="${contextPath }/Me">个人中心</a></li>
        <li>欢迎你，<b>${fn:escapeXml(user.nickName) }</b>！</li>
      </ul>
    </div>
    </c:if>
    
    
  </div>
  <div id="top"><img src="${staticResources}/image/zhuye_04.gif" width="1024" height="153" alt=""></div>
  <div id="nav" style="background:url(${staticResources}/image/zhuye_06.gif)">
    <ul>
      <li><a href="${contextPath }/Homepage">首页</a></li>
      <li><a href="${contextPath }/Books/Search">交易广场</a></li>
      <li><a href="${contextPath }/Auctions/Search">拍卖中心</a></li>
      <li><a href="#">读者推荐</a></li>
      <li><a href="${contextPath }/Comment/ListComments">留言板</a></li>
      <li><a href="#">新手指南</a></li>
    </ul>
  </div>
</div>
<!--头部结束-->
<div class="main">
     <div class="lmain"><span><img src="${staticResources}/image/zhuye_10.gif" width="179" height="35" alt=""></span>
        <dl class="tsfl">
           
           <dd> <a href="#">小说 </a></dd>
           <dt><a href="#"> 言情 武侠 名著 军事 悬疑 职场</a></dt>
           <dd><a href="#"> 期刊</a></dd>
           <dt><a href="#"> 财经 漫画 英文 杂志</a></dt>
           <dd><a href="#">文学</a></dd>
           <dt><a href="#"> 诗歌 散文 文集 外国诗歌</a></dt>
           <dd><a href="#"> 教科书             </a></dd>
           <dt><a href="#">化学 物理 生物 英语 计算机 药理</a></dt>
           <dd><a href="#"> 教辅用书</a></dd>
           <dt><a href="#"> 药院 中药院 商院 生科院 理学院</a></dt>
           <dd><a href="#"> 人文社科</a></dd>
           <dt><a href="#"> 商务礼仪 宗教 历史 法律 心理学</a></dt>
           <dd><a href="#"> 艺术</a></dd>
           <dt><a href="#"> 摄影 绘画 音乐 舞蹈 书法 篆刻</a></dt>
           <dd><a href="#"> 成功励志</a></dd>
           <dt><a href="#"> 礼仪 人际交往 口才 留学 哲学</a></dt>
           <dd><a href="#"> 其他</a></dd>
           <dt><a href="#">...</a></dt>
         </dl>
         <dl class="phb">
            <span><img src="${staticResources}/image/zhuye_37.gif" width="177" height="35" alt=""></span>
            <div id="nn">
               <ul>
            <li><a href="#">教科</a></li>
            <li><a href="#">小说</a></li>
            <li><a href="#">期刊</a></li>
            <li><a href="#">其他</a></li>
               </ul>
            </div>
          <dd><a href="#"><img src="${staticResources}/image/zhuye_43.gif" width="64" height="74" alt="">书名：<br>价格：<br>卖家信息：</a>          </dd>
          <dd><a href="#"><img src="${staticResources}/image/zhuye_43.gif" width="64" height="74" alt="">书名：<br>价格：<br>卖家信息：</a>          </dd>
          <dd><a href="#"><img src="${staticResources}/image/zhuye_43.gif" width="64" height="74" alt="">书名：<br>价格：<br>卖家信息：</a>          </dd>
        </dl>
     </div>
  <div class="rmain">
	     <form method="get" action="Search" style="height:40px;">
         <div class="search">
		 
		     <div class="ssleft">
			    <input name="keyword" type="text" value="" placeholder="请输入搜索内容 " style="width:365px; height:35px; margin:6px 5px 0px 100px; font-size:16px;">
			 </div>
			 <div class="ssright">
			      <input type="image" src="${contextPath }/static/image/searchbookresult_03.gif" style=" text-align:center; margin:-14.5px 0px 0px 0px;width:72px;  height:35px;" class="botton" alt="" name="" value=""> </div>
			 <div>
			    <select name="category" id="category" size="" style="width:85px; height:35px; margin:6px 0px 0px 0px; font-size:24px; line-height:30px;">
					       <option value="0" selected="selected">全部</option>
					       <c:forEach var="bookcategory" items="${bookcategories}">
						     <option value="${bookcategory.CID }" >${fn:escapeXml(bookcategory.name) }</option>
					       </c:forEach>
					</select>
			 </div>
		  </div>
		   
		 <div>
		          
		 </div>
		 </form>
		 
	<br/>
	
		 <div class="rank">
		      <div id="nav2">
		        <ul>
		        
		         <c:choose>
		          <c:when test="${param.orderby eq 1 }">
		           <c:choose>
		            <c:when test="${param.orderbytype eq 1 }">
		             <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }" class="nav2hightlight">信誉度↑</a></li>
		            </c:when>
		            <c:when test="${param.orderbytype eq 2 }">
		             <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }&orderby=1&orderbytype=1" class="nav2hightlight">信誉度↓</a></li>
		            </c:when>
					<c:otherwise>
					 <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }&orderby=1&orderbytype=2">信誉度</a></li>
					</c:otherwise>
		           </c:choose>
		          </c:when>
		          <c:otherwise>
		           <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }&orderby=1&orderbytype=2">信誉度</a></li>
		          </c:otherwise>
		         </c:choose>
		         
		         <c:choose>
		          <c:when test="${param.orderby eq 2 }">
		           <c:choose>
		            <c:when test="${param.orderbytype eq 1 }">
		             <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }&orderby=2&orderbytype=2" class="nav2hightlight">价格↑</a></li>
		            </c:when>
		            <c:when test="${param.orderbytype eq 2 }">
		             <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }" class="nav2hightlight">价格↓</a></li>
		            </c:when>
					<c:otherwise>
					 <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }&orderby=2&orderbytype=1">价格</a></li>
					</c:otherwise>
		           </c:choose>
		          </c:when>
		          <c:otherwise>
		           <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }&orderby=2&orderbytype=1">价格</a></li>
		          </c:otherwise>
		         </c:choose>
		         
		         <c:choose>
		          <c:when test="${param.orderby eq 3 }">
		           <c:choose>
		            <c:when test="${param.orderbytype eq 1 }">
		             <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }" class="nav2hightlight">新旧↑</a></li>
		            </c:when>
		            <c:when test="${param.orderbytype eq 2 }">
		             <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }&orderby=3&orderbytype=1" class="nav2hightlight">新旧↓</a></li>
		            </c:when>
					<c:otherwise>
					 <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }&orderby=3&orderbytype=2">新旧</a></li>
					</c:otherwise>
		           </c:choose>
		          </c:when>
		          <c:otherwise>
		           <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }&orderby=3&orderbytype=2">新旧</a></li>
		          </c:otherwise>
		         </c:choose>
		         
		         <c:choose>
		          <c:when test="${param.orderby eq 4 }">
		           <c:choose>
		            <c:when test="${param.orderbytype eq 1 }">
		             <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }" class="nav2hightlight">笔记↑</a></li>
		            </c:when>
		            <c:when test="${param.orderbytype eq 2 }">
		             <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }&orderby=4&orderbytype=1" class="nav2hightlight">笔记↓</a></li>
		            </c:when>
					<c:otherwise>
					 <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }&orderby=4&orderbytype=2">笔记</a></li>
					</c:otherwise>
		           </c:choose>
		          </c:when>
		          <c:otherwise>
		           <li><a href="?keyword=${su:encodeUriComponent(param.keyword) }&category=${su:encodeUriComponent(param.category) }&orderby=4&orderbytype=2">笔记</a></li>
		          </c:otherwise>
		         </c:choose>
                </ul>
		      </div>
		 </div>
		 
		 
		
		 
		 <c:forEach var="bookitem" items="${page.records}">
		 <div class="lists">
		     <div class="list">
			  <c:choose>
			    <c:when test="${empty bookitem.front_end_picpath }">
			      <img src="${staticResources}/image/bepics_none.jpg" style="max-width:73px;max-height:86px" alt="">
			    </c:when>
			    <c:otherwise>
			    <img src="${userContents}/bepics/${bookitem.front_end_picpath}" style="max-width:73px;max-height:86px" alt="">
			    </c:otherwise>
			  </c:choose>
		    
			     <a href="ShowBook?beid=${bookitem.beID }">书名：${fn:escapeXml(bookitem.name)}</a><big>价格：</big><b>${fn:escapeXml(bookitem.price)}</b><br />
				 <small>新旧程度：${fn:escapeXml(bookitem.condition)}</small>&nbsp;<small>笔记：${fn:escapeXml(bookitem.hasNote)}</small>
				 
			 </div>
			 <div>
			    <div class="shopper">
			       <small>卖家：</small><small><a href="#">${fn:escapeXml(bookitem.owner.nickName)}</a></small><br>
				   <small>信誉度：${fn:escapeXml(bookitem.owner.creditPoint)}</small>
			    </div>
				<div class="botton">
				   <a href="ShowBook?beid=${bookitem.beID }"><img src="${staticResources}/image/listbook_14.gif" width="102" height="32" alt=""></a><a href="javascipt:void(0)" onclick = "collect(${bookitem.beID});return false;"> <img src="${staticResources}/image/listbook_16.gif" width="102" height="32" alt=""></a>
				</div>
				
			 </div>
			 
		 </div>
		 </c:forEach>
<!--一个信息结束-->	 
	<div id="page">
		    <ul>
		   
		    
		   
		    
		    <c:choose>
		    <c:when test = "${page.hasPrevious}">
		     <li><a href="?keyword=${keywordEncoded}&curPage=1&pageSize=${page.pageSize}">首页</a></li>
            <li><a  href="?keyword=${keywordEncoded}&curPage=${page.prePage}&pageSize=${page.pageSize}">上一页</a></li>
		    </c:when>
		    <c:otherwise>
		    <li class = "currentpage">已到首页</li>
		    </c:otherwise>
		    </c:choose>
		  

           
            <c:if test="${page.currentPage-3 gt 0}">
            <li><a href = "?keyword=${keywordEncoded}&curPage=${page.currentPage-3}&pageSize=${page.pageSize}">${page.currentPage-3}</a></li>
            </c:if>
            <c:if test="${page.currentPage-2 gt 0}">
            <li><a href = "?keyword=${keywordEncoded}&curPage=${page.currentPage-2}&pageSize=${page.pageSize}">${page.currentPage-2}</a></li>
            </c:if>
             <c:if test="${page.currentPage-1 gt 0}">
            <li><a href = "?keyword=${keywordEncoded}&curPage=${page.currentPage-1}&pageSize=${page.pageSize}">${page.currentPage-1}</a></li>
            </c:if>
            <li class = "currentpage"><b>${page.currentPage}</b></li>
             
             <c:if test="${page.maxPage - page.currentPage -0 gt 0}">
            <li><a href = "?keyword=${keywordEncoded}&curPage=${page.currentPage+1}&pageSize=${page.pageSize}">${page.currentPage+1}</a></li>
            </c:if>
            <c:if test="${page.maxPage - page.currentPage -1 gt 0}">
            <li><a href = "?keyword=${keywordEncoded}&curPage=${page.currentPage+2}&pageSize=${page.pageSize}">${page.currentPage+2}</a></li>
            </c:if>
            <c:if test="${page.maxPage - page.currentPage -2 gt 0}">
            <li><a href = "?keyword=${keywordEncoded}&curPage=${page.currentPage+3}&pageSize=${page.pageSize}">${page.currentPage+3}</a></li>
            </c:if>
         
          
            
            <c:choose>
		    <c:when test = "${page.hasNext}">
            <li><a href="?keyword=${keywordEncoded}&curPage=${page.nextPage}&pageSize=${page.pageSize}">下一页</a></li>
            <li><a href="?keyword=${keywordEncoded}&curPage=${page.maxPage}&pageSize=${page.pageSize}">末页</a></li>
		    </c:when>
		    <c:otherwise>
		    <li class = "currentpage">已到末页</li>
		    </c:otherwise>
		    </c:choose>
		    
		    
		  

            </ul>
		</div> 
		
     </div>
     
     
     
</div>
<!--中间部分结束-->
<div id="bottom"><img src="${staticResources}/image/zhuye_47.gif" width="1024" height="86" alt=""></div>

</body>
</html>
